package com.xiaotu.dao.sw;

import com.xiaotu.vo.SwCommentAuthVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zhangxiao
 * @create 2021-09-03 10:09
 */
public interface SwCommentAuthMapper {

    @Select("<script>" +
            " SELECT " +
            " t1.sw_comment_id, " +
            " t3.NAME be_comment_star_name, " +
            " t4.nick_name comment_user_name, " +
            " t2.comment_time, " +
            " t2.comment_content " +
            "FROM " +
            " tab_sw_comment t1 " +
            " LEFT JOIN tab_sw_comment_info t2 ON t1.comment_id = t2.comment_id " +
            " LEFT JOIN tab_star_info t3 ON t1.be_comment_star_id = t3.starid " +
            " LEFT JOIN tab_wx_user t4 ON t1.comment_user_id = t4.userid  " +
            "WHERE " +
            " t1.auth_status = #{authStatus}  " +
            "ORDER BY " +
            " t2.comment_time DESC " +
            "</script>")
    List<SwCommentAuthVo> getCommentAuths(Integer authStatus);

    @Update("<script>" +
            " UPDATE `tab_sw_comment` SET `auth_status` = #{authStatus} WHERE `sw_comment_id` IN ( " +
            " <foreach collection='ids' item = 'id' separator = ','> " +
            " #{id} " +
            " </foreach> " +
            " ) " +
            "</script>")
    void handleCommentApproves(@Param("ids") String[] ids, @Param("authStatus") Integer authStatus);
}
